<?php

namespace IDock\Insurance\TAIC\Request;

use IDock\Http\RequestMethod;
use IDock\Insurance\TAIC\Response\VehicleModelResponse;
use IDock\Visitor\PolicyPaymentVisitor;

class PolicyPaymentRequest extends AllTAICRequest
{
    protected $route = 'common/pay/applyPay.do';

    protected $response = VehicleModelResponse::class;

    protected $urlTip = '支付';

    protected $method = RequestMethod::GET;

    protected $pageUrl;

    /**
     * @var  PolicyPaymentVisitor $visitor
     */
    protected $visitor;

    public function setPageUrl($pageUrl)
    {
        $this->pageUrl = $pageUrl;
    }

    public function generate(): array
    {
        $this->tradeNo = $this->visitor->argc['tradeNo'] ?? '';

        return [
            'orderNo' => $this->tradeNo,
            'payType' => '7',
            'pageUrl' => $this->pageUrl,
        ];
    }

    public function getPayUrl(): string
    {
        return $this->gateway . '/' . $this->route . "?" . http_build_query($this->generate());
    }
}